<template>
	<view class="">
		<!-- <das-ipt @SearchEvents="search()" :prompt="'请输入姓名/日期/手机号'"></das-ipt> -->
		<view class="select">
			<view class="u-flex" @tap="showYear = true">
				<input style="color: #FFFFFF;" placeholder-style="color:#FFFFFF" class="ym" type="text"
					v-model="nowYear.showTime" disabled placeholder="请选择年月" />
				<u-icon name="arrow-down-fill" color="#FFFFFF"></u-icon>
			</view>
			<u-picker mode="time" v-model="showYear" :params="params" @confirm="confirm"></u-picker>
		</view>
		<view class="all">
			<view class="list-item" v-for="(item,index) in dangerList" :key='index'
				@tap="getDetails(item.status,item.id)">
				<view class="list-item-content">
					<view class="items">
						<text class="item-title">检查部门：</text>
						<text class="colorhui">{{item.inspect}}</text>
					</view>
					<view class="items">
						<text class="item-title">检查人：</text>
						<text class="colorhui">{{item.inspect_people}}</text>
					</view>
					<view class="items">
						<text class="item-title">检查地点：</text>
						<text class="colorhui">{{item.inspect_place}}</text>
					</view>
					<view class="items">
						<text class="item-title">检查时间：</text>
						<text class="colorhui">{{item.inspect_time}}</text>
					</view>
					<view class="items">
						<text class="item-title">主要内容：</text>
						<text class="colorhui">{{item.content}}</text>
					</view>
					<!-- <view class="items">
						<text class="item-title">检查事项：</text>
						<text class="colorhui">{{item.inspect_matter}}</text>
					</view>
					<view class="items">
						<text class="item-title">检查记录：</text>
						<text class="colorhui">{{item.inspect_record}}</text>
					</view>
					<view class="items">
						<text class="item-title">检查结果：</text>
						<text class="colorhui">{{item.inspect_result}}</text>
					</view> -->
					<view class="items">
						<text class="item-title">处理意见：</text>
						<text class="colorhui">{{item.opinion}}</text>
					</view>
					<view class="items">
						<text class="item-title">完成期限：</text>
						<text class="colorhui">{{item.term_time}}</text>
					</view>
					<view class="items">
						<text class="item-title">状态：</text>

						<template v-if="item.status ==1">
							<text class="colorhui">待审核</text>
						</template>
						<template v-if="item.status ==2">
							<text class="colorhui">已通过</text>
						</template>
						<template v-if="item.status ==3">
							<text class="colorhui">驳回</text>
						</template>
					</view>
					<view class="items"  v-if="item.status ==3">
						<text class="item-title">驳回原因：</text>
						<text class="colorhui">{{item.reason || ''}}</text>
					</view>
				</view>
			</view>
			<u-empty v-if="dangerList.length == 0" class="nomodel" text="暂无巡检记录" mode="list"></u-empty>
		</view>
		<das-add @func="func"></das-add>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				dangerList: [],
				params: {
					year: true,
					month: true,
					day: false,
					hour: false,
					minute: false,
					second: false
				},
				showYear: false,
				// startYear:'',
				nowYear: {
					showTime: '', //前端展示的时间
					timeYear: '', //传给后台的时间
				}
			}
		},
		onShow() {
			// var date = new Date();
			// let y = date.getFullYear();
			// let m = date.getMonth()+1;
			// this.startYear = y+'-'+m
			this.getInstallDetail()
		},
		onLoad() {

		},
		methods: {
			func() {
				this.$navTo('/pagesB/rithcheck/security?addType=1' )
			},
			chooseYear() {
				this.showYear = true
			},
			getDetails(status,id){
			    if(status==3){
			     console.log('驳回');
			     this.$navTo(`/pagesB/rithcheck/security?status=${status}&id=${id}`)
			    }
			    else{
			     this.$navTo('/pagesB/rithcheck/details/record?id='+id)
			    }
			   },
			// 获取安装数据
			getInstallDetail() {
				let that = this
				uni.request({
					url: this.$url + '/staff.Inspect/getList',
					method: 'POST',
					header: {
						token: uni.getStorageSync('token'),
					},
					data: {
						user: uni.getStorageSync('login') == '用户' ? 1 : 2,
						choose_time: that.nowYear.timeYear
					},
					success: (res) => {
					
						if (res.data.code == 1) {
							// console.log(res.data)
							that.dangerList = res.data.data;
							// console.log(that.dangerList)
						} else {
							that.$showToast(res.data.msg)
						}
					}
				})
			},
			search(e) {
				console.log(e);
			},
			confirm(e) {
				this.nowYear.showTime = e.year + '年' + e.month + '月'
				this.nowYear.timeYear = e.year + '-' + e.month
				this.getInstallDetail()
			}
		}
	}
</script>

<style lang="less" scoped>
	.select {
		background: #003690;
		padding: 20rpx 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		.ym {
			min-width: 120rpx;
			max-width: 170rpx;
		}
	}

	.all {
		padding: 22rpx 32rpx;
		min-height: 100vh;
		background: #F1F1F1;
	}

	.list-item {
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 6rpx rgba(0, 30, 57, 0.1);
		border-radius: 16rpx;
		display: flex;
		padding: 5rpx 20rpx;
		margin-bottom: 22rpx;
		align-items: center;
		justify-content: space-between;

		.list-item-content {
			width: 452rpx;
			padding-bottom: 5rpx;

			.items {
				display: flex;
				align-items: center;
				padding: 5rpx 0;

				.portrait {
					width: 36rpx;
					height: 36rpx;
				}

				.item-title {
					width: 140rpx;
				}

				.colorhui {
					color: #999999;
				}
			}
		}

		.list-item-status {
			width: 171rpx;
			height: 174rpx;

			.status-img {
				display: block;
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
